package com.boot.springboot.component.qlexpress;

import com.boot.springboot.component.qlexpress.service.DecryptHelper;
import com.boot.springboot.component.qlexpress.service.EncryptHelper;
import lombok.extern.slf4j.Slf4j;

import java.util.HashMap;

@Slf4j
public class DecryptTest {

   public static void main(String[] args) {
      String testWifiContent = "{\"logId\":\"234324\",\"name\":\"wifi\",\"mac\":\"aaaaabbddd\",\"activeId\":\"343\",\"brand\":\"skyworth\",\"model\":\"18S18\",\"chip\":\"c833\",\"core\":\"HuaweiHaisi\",\"sysVer\":\"6.23423.2342\",\"androidVer\":12,\"appVer\":12,\"appVerName\":\"aaaa\",\"appPkg\":\"com.coocaa.tianci.vol\",\"sdkVer\":12,\"cOpenId\":\"xxx\",\"logTime\":123123123,\"osBootTime\":123123123,\"data\":{\"list\":[{\"ssid\":\"openwrt-5G\",\"rssi\":-90,\"mac\":\"aaa\"},{\"ssid\":\"coocaatest4\",\"rssi\":-90,\"mac\":\"bbb\"}]}}";
      HashMap<String, String> map = EncryptHelper.doEncrypt(testWifiContent, "");
      String key = map.get("key");
      //key ="nNHeWYZchkQ6pGhjTmJtJpZDcAYMS7fDdn89wMr0NrH-NU0zC0lyWp_qNP6PM-FuIXxU0gXFJY4_tqOynRUDz1JPZY3-f5O_rNGOthtcu0ZWANXSXSmQs6181BP5dhwssPEtpz8jaGBw5NE6Gb6Pm0-vDqMg_GyTmZt7IK3rOz8=";
      String content = map.get("content");
      //content = "qDBkjCi9PBFo_yCdVS3Sjhv9PYDnTkxyB66tbHiff0SOG9D3_Phh7QNGy0xC7FbedXsY3dej_zqHN57Fgvcs2KrRHiEg5iC3S4UKxGAgOeHgXvdsG2kFvrCJ0h9rwOEvE_YQUzaS9-cCHFqQX7s5OdGEIkOTtx7ozyoiIqfIfqs98HlFXD7Pb9wtCvWnusuhI-BdDnCLuH4MsgVrvcY42EtUEPDEoSmC5pPmM9S6SLq91fjJEBzgHYM510pAcwRZAO4jc86S1RsM3If2uNuaBzcdqTq_XkD8IrmiUJrien34YAMq-9DlevdEP6hK_dassY6LYJjV8jb0wD-BM-cKL3L4Zg2Zb6yRrABECppHp5bB3CaZcBmZmb0ZTwWftRprMWo5yASl9yLqz-lXK6ur2aals4nsn0lK3JOz5ucB2wDWmnpP2HRvJhm2rOLq_ub1OS7XY3Roxkn9B5GZzlW4gjTvuGOFxcLtN8fp8oOBpI2NXU1bW7eDVOlgks8_gb15bSjp4PizTukT-V-fJpx6tA==";
      String decrypt = DecryptHelper.decrypt(content, key);
      log.info("begin****************wifi****************");
      log.info(decrypt);
      log.info("-----------key------:\n{}\n", key);
      log.info("-----------content------:\n{}\n", content);
      log.info("end****************wifi****************");

      String testBlueContent = "[{\"logId\":\"234324\",\"name\":\"blue\",\"mac\":\"aaaaabbddd\",\"activeId\":\"343\",\"brand\":\"skyworth\",\"model\":\"18S18\",\"chip\":\"c833\",\"core\":\"HuaweiHaisi\",\"sysVer\":\"6.23423.2342\",\"androidVer\":12,\"appVer\":12,\"appVerName\":\"aaaa\",\"appPkg\":\"com.coocaa.tianci.vol\",\"sdkVer\":12,\"cOpenId\":\"xxx\",\"logTime\":123123123,\"osBootTime\":123123123,\"data\":{\"list\":[{\"bln\":\"horor-23fs\",\"mac\":\"192.168.1.5\",\"tn\":\"华为\",\"dn\":\"honor\",\"rssi\":-90},{\"bln\":\"horor-23fm\",\"mac\":\"192.168.1.6\",\"tn\":\"华为\",\"dn\":\"honor\",\"rssi\":-90}]}}]";
      HashMap<String, String> map2 = EncryptHelper.doEncrypt(testBlueContent, "");
      String key2 = map2.get("key");
      String content2 = map2.get("content");
      String decrypt2 = DecryptHelper.decrypt(content2, key2);
      log.info("begin****************blue****************");
      log.info(decrypt2);
      log.info("-----------key------:\n{}\n", key2);
      log.info("-----------content------:\n{}\n", content2);
      log.info("end****************blue****************");

      String testRouterDeviceContent = "[{\"logId\":\"234324\",\"name\":\"routerDevice\",\"mac\":\"aaaaabbddd\",\"activeId\":\"343\",\"brand\":\"skyworth\",\"model\":\"18S18\",\"chip\":\"c833\",\"core\":\"HuaweiHaisi\",\"sysVer\":\"6.23423.2342\",\"androidVer\":12,\"appVer\":12,\"appVerName\":\"aaaa\",\"appPkg\":\"com.coocaa.tianci.vol\",\"sdkVer\":12,\"cOpenId\":\"xxx\",\"logTime\":123123123,\"osBootTime\":123123123,\"data\":{\"list\":[{\"mac\":\"A923432224\",\"ip\":\"192.168.1.5\",\"tn\":\"华为\",\"dn\":\"honor\"},{\"mac\":\"12312423fdf\",\"ip\":\"192.168.2.11\",\"tn\":\"xiaomi\",\"dn\":\"honor\"}]}}]";
      HashMap<String, String> map3 = EncryptHelper.doEncrypt(testRouterDeviceContent, "");
      String key3 = map3.get("key");
      String content3 = map3.get("content");
      String decrypt3 = DecryptHelper.decrypt(content3, key3);
      log.info("begin****************routerDevice****************");
      log.info(decrypt3);
      log.info("-----------key------:\n{}\n", key3);
      log.info("-----------content------:\n{}\n", content3);
      log.info("end****************routerDevice****************");

      String testDeviceVolumeContent = "{\"activeId\":\"86102339\",\"androidVer\":28,\"appPkg\":\"com.coocaa.aisdk.testapp\",\"appVer\":1,\"appVerName\":\"1.0\",\"brand\":\"Skyworth\",\"chip\":\"8S47\",\"core\":\"\",\"data\":{\"new\":77,\"old\":10},\"logId\":\"4e55c697926a845a6b1742b819459562\",\"logTime\":1642764873635,\"mac\":\"b00247b98c91\",\"model\":\"E2A\",\"name\":\"autoNightVol\",\"osBootTime\":33123803,\"sdkVer\":1000000,\"sysVer\":\"7.00.211213\"}";
      HashMap<String, String> map4 = EncryptHelper.doEncrypt(testDeviceVolumeContent, "");
      String key4 = map4.get("key");
      String content4 = map4.get("content");
      String decrypt4 = DecryptHelper.decrypt(content4, key4);
      log.info("begin****************volumeChange****************");
      log.info(decrypt4);
      log.info("-----------key------:\n{}\n", key4);
      log.info("-----------content------:\n{}\n", content4);
      log.info("end****************volumeChange****************");

   }

}
